#include "widget.h"
#include "ui_widget.h"
#include <QShortcut>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QShortcut* ret = new QShortcut(this);
    ret->setKey(QKeySequence("+"));
    QShortcut* ret2 = new QShortcut(this);
    ret2->setKey(QKeySequence("-"));
    connect(ret, &QShortcut::activated, this, &Widget::add);
    connect(ret2, &QShortcut::activated, this, &Widget::sub);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_horizontalSlider_valueChanged(int value)
{
    ui->label->setText("当前值为：" + QString::number(value));
}

void Widget::add()
{
    ui->horizontalSlider->setValue(ui->horizontalSlider->value() + 5);
}

void Widget::sub()
{
    ui->horizontalSlider->setValue(ui->horizontalSlider->value() - 5);
}
